/* Component info --------------------------------------------------------------
 * Author   : PURESUN
 * Version  : V1.0.0
 * Notes    : ui component header file
 * Update   : 2023-12-18
 -----------------------------------------------------------------------------*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __UI_H__
#define __UI_H__

/* Includes ------------------------------------------------------------------*/
#include "pub_types.h"
#include "lvgl/lvgl.h"
#include "page_main.h"
#include "page_start.h"
#include "status_bar/status_bar.h"

/* Exported macro ------------------------------------------------------------*/
#define UI_STATUS_BAR_HEIGHT 30
#define UI_STATUS_BAR_WIDTH LV_HOR_RES_MAX

#define UI_LEFT_BOX_HEIGHT LV_VER_RES_MAX - UI_STATUS_BAR_HEIGHT
#define UI_LEFT_BOX_WIDTH 80

#define UI_MAIN_BOX_WIDTH LV_HOR_RES_MAX - UI_LEFT_BOX_WIDTH
#define UI_MAIN_BOX_HEIGHT LV_VER_RES_MAX - UI_STATUS_BAR_HEIGHT

#define LAYOUT_FILE_PATH "/layout.ui"
#define MAX_THEME_NUM 5
#define MAX_PAGE_NUM 5
#define MAX_CONTENT_NUM 32
/* Exported typedef ----------------------------------------------------------*/

typedef enum
{
    LID_NULL = 0,
    LID_PM_GLOMMY,
    LID_PM_LOG_LABLE,
    LID_PM_VACUUM_LABLE,
    LID_PM_BTN_START,
    LID_PM_POWER_VALUE_LABEL,
    LID_BAR_TIME,
    LID_PM_RUNTIME,
    LID_PM_VACUUM_BOX,
    /*DEV MPM*/
    LID_DEV_MPM_RS,
    LID_DEV_MPM_CURRENT,
    LID_DEV_MPM_VOLTAGE,
    LID_DEV_MPM_TEMPERATURE,
    /*DEV MPM RADIO*/
    LID_DEV_RADIO_MPM_FAIL_START,
    LID_DEV_RADIO_MPM_OVERLOAD,
    LID_DEV_RADIO_MPM_NORMAL_SPEED,
    LID_DEV_RADIO_MPM_HIGH_SPEED,
    LID_DEV_RADIO_MPM_WORKING,
    LID_DEV_RADIO_MPM_OVERCURRENT,
    LID_DEV_RADIO_MPM_OVERHEAT,
    LID_DEV_RADIO_MPM_TIMEOUT,
    /*DEV JPM*/
    LID_DEV_JPM_RS,
    LID_DEV_JPM_CURRENT,
    LID_DEV_JPM_VOLTAGE,
    LID_DEV_JPM_TEMPERATURE1,
    LID_DEV_JPM_TEMPERATURE2,
    /*DEV JPM RADIO*/
    LID_DEV_RADIO_JPM_WORKING,
    LID_DEV_RADIO_JPM_FAULT,

    /*DEV RADIO*/
    LID_DEV_RADIO_JPUMP,
    LID_DEV_RADIO_VALVE_MAIN,
    LID_DEV_RADIO_MPUMP,
    LID_DEV_RADIO_VALVE_RELEASE,
    LID_DEV_BTN_DEVICE_CTL,

    LID_DEV_VACUUM_LABEL,
    LID_DEV_VACUUM_COLD_GAUGE_LABEL,
    LID_MAX
} lv_obj_id_t;

extern lv_obj_t *lobj[LID_MAX];

typedef struct __ui_left_box_btn_t__
{
    lv_obj_t *btn;
    lv_obj_t *label;
    lv_obj_t *icon;
    bool select;
} left_box_btn_t;

typedef struct __ui_left_box_t__
{
    lv_obj_t *box;
    lv_coord_t box_w;
    lv_coord_t box_h;
    lv_coord_t btn_w;
    lv_coord_t btn_h;
    left_box_btn_t home;
    left_box_btn_t program;
    left_box_btn_t device;
    left_box_btn_t vacuum;
    left_box_btn_t setting;
} left_box_t;

// typedef struct __ui_main_box_

typedef struct __ui_main_box_t__
{
    lv_obj_t *box;
    lv_coord_t box_w;
    lv_coord_t box_h;
    struct
    {
        lv_obj_t *label;
        struct
        {
            lv_obj_t *box;
            lv_obj_t *glommy;
            lv_obj_t *btn_release;
        } mainctl;
        lv_obj_t *coa_plot_box;
        lv_obj_t *coa_plot;
        lv_obj_t *vacuum_box;
        lv_obj_t *vacuum_plot;
        lv_obj_t *power_slider_box;
        lv_obj_t *power_slider_title;
        lv_obj_t *power_slider;
        lv_obj_t *cover;
        // lv_obj_t *lable_vaacum;
        lv_obj_t *lable_log;
    } page_main;
    struct
    {
        lv_obj_t *label;
        lv_obj_t *txt_name;
        lv_obj_t *txt_desc;
        lv_obj_t *txt_power_set;
        lv_obj_t *txt_duration;
        lv_obj_t *txt_cooldown;
        lv_obj_t *txt_notes;
        int pro_id;
        int step_id;
    } page_program;
    struct
    {
        lv_obj_t *label;

        lv_obj_t *mpump_box;
        lv_obj_t *mpump_title;
        lv_obj_t *mpump_info_box;
        lv_obj_t *mpump_rotational_speed;
        lv_obj_t *mpump_current;
        lv_obj_t *mpump_voltage;
        lv_obj_t *mpump_temperature;
        lv_obj_t *btn_low_rs;
        lv_obj_t *btn_high_rs;
        lv_obj_t *btn_mpump_reset;
        lv_obj_t *label_mpump_reset;
        lv_obj_t *mpump_status_box;
        struct
        {
            lv_obj_t *timeout_box;
            lv_obj_t *overheat_box;
            lv_obj_t *overcurrent_box;
            lv_obj_t *working_box;
            lv_obj_t *high_speed_box;
            lv_obj_t *normal_speed_box;
            lv_obj_t *overload_box;
            lv_obj_t *fail_start_box;
        } mpump_status;
        lv_obj_t *jpump_box;
        lv_obj_t *jpump_title;
        lv_obj_t *jpump_info_box;
        lv_obj_t *jpump_voltage;
        lv_obj_t *jpump_current;
        lv_obj_t *jpump_rotational_speed;
        lv_obj_t *jpump_temperature1;
        lv_obj_t *jpump_temperature2;
        lv_obj_t *btn_jpump_reset;
        lv_obj_t *label_jpump_reset;
        lv_obj_t *jpump_status_box;
        struct
        {
            lv_obj_t *working_box;
            lv_obj_t *fault;
        } jpump_status;
        lv_obj_t *device_ctl_box;
        lv_obj_t *device_ctl_title;

        lv_obj_t *vavle_main_status_box;
        lv_obj_t *vavle_main_status_txt;
        lv_obj_t *vavle_release_status_box;
        lv_obj_t *vavle_release_status_txt;

        lv_obj_t *jpump_ctl_box;
        lv_obj_t *jpump_ctl_txt;

        lv_obj_t *mpump_ctl_box;
        lv_obj_t *mpump_ctl_txt;

        lv_obj_t *btn_close_all_device;
        lv_obj_t *label_close_all_device;

        lv_obj_t *btn_lock;
        lv_obj_t *label_lock;

        lv_obj_t *btn_unlock;
        lv_obj_t *label_unlock;

        lv_obj_t *vacuum_box;
        lv_obj_t *vacuum_info_box;
        lv_obj_t *vacuum_title;
        lv_obj_t *vacuum_label;
        lv_obj_t *vacuum_cold_gauge_label;

        lv_obj_t *device_ctl_btn;
        lv_obj_t *device_ctl_btn_label;
    } page_device;
    struct
    {
        lv_obj_t *label;
    } page_vacuum;
    struct
    {
        lv_obj_t *label;
        struct
        {
            lv_obj_t *box;
            lv_obj_t *label;
            lv_obj_t *btn;
            lv_obj_t *icon;
        } mode;
        struct
        {
            lv_obj_t *box;
            lv_obj_t *label;
            lv_obj_t *btn;
            lv_obj_t *icon;
        } log_output;

    } page_setting;
} main_box_t;

typedef struct __start_container_t__
{
    lv_obj_t *container;
    lv_obj_t *logo;
    lv_obj_t *img_loading;
    lv_anim_t loading_am;
    lv_obj_t *label;
} start_t;

typedef struct __ui_t__
{
    lv_obj_t *scr;
    lv_obj_t *keyboard;
    lv_obj_t *toast;
    lv_timer_t *timer_1;
    struct
    {
        lv_ft_info_t size_16;
        lv_ft_info_t size_18;
        lv_ft_info_t size_20;
        lv_ft_info_t size_24;
        lv_ft_info_t size_36;
    } fnt;
    start_t start; // start page
    status_bar_t status_bar;
    left_box_t left_box;
    main_box_t main_box;
} ui_t;
/* Exported variables --------------------------------------------------------*/

/* Exported function prototypes ----------------------------------------------*/
void ui_init(ui_t *ui);

#endif /* __UI_H__ */